package com.example.hospital.api.common.exception;

import com.example.hospital.api.common.handler.BaseErrorInfoInterface;

/**
 * ClassName: BaseException
 * Package: com.example.hospital.api.common.exception
 * Description:
 *
 * @Author JJQ
 * @create 2024/7/21 0021 23:30
 * @Version 1.0
 */
public class BaseException extends RuntimeException{
    private static final long serialVersionUID = 1L;

    /**
     * 错误码
     */
    protected String errorCode;
    /**
     * 错误信息
     */
    protected String errorMsg;

    public BaseException(){
        super();
    }

    public BaseException(BaseErrorInfoInterface infoInterface){
        super(infoInterface.getResultCode());
        this.errorCode = infoInterface.getResultCode();
        this.errorMsg = infoInterface.getResultMsg();
    }

    public BaseException(BaseErrorInfoInterface errorInfoInterface, Throwable cause) {
        super(errorInfoInterface.getResultCode(), cause);
        this.errorCode = errorInfoInterface.getResultCode();
        this.errorMsg = errorInfoInterface.getResultMsg();
    }

    public BaseException(String errorMsg) {
        super(errorMsg);
        this.errorMsg = errorMsg;
    }

    public BaseException(String errorCode, String errorMsg) {
        super(errorCode);
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    public BaseException(String errorCode, String errorMsg, Throwable cause) {
        super(errorCode, cause);
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    public String getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }

    public String getErrorMsg() {
        return errorMsg;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    @Override
    public Throwable fillInStackTrace(){
        return this;
    }

}
